#include"init_widget.h"

init_widget::init_widget(Q3DBars*bar):m_bars(bar),
    x_roation(15),
    y_roation(15)
{
    m_bars->scene()->activeCamera()->setCameraPosition(x_roation, y_roation);
    QWidget *container = QWidget::createWindowContainer(m_bars);
    container->setMinimumWidth(600);
    container->setMinimumHeight(500);
    widget=new QWidget;
    widget->setMinimumSize(700,600);
    box=new QGroupBox("功能设置:");
    box->setFixedSize(175,520);
    hb=new QHBoxLayout;
    hb->addWidget(container);
    hb->addWidget(init_box(box));
    widget->setLayout(hb);
    QObject::connect(slider1,SIGNAL(valueChanged(int)),this,SLOT(slot_slider1(int)));
    connect(slider2,SIGNAL(valueChanged(int)),this,SLOT(slot_slider2(int )));
    connect(slider3,SIGNAL(valueChanged(int)),this,SLOT(slot_slider3(int)));


}
void init_widget::show_widget()
{
    //widget->show();

    widget->show();
}
//初始化Box，将组件放置到BOX
QGroupBox *init_widget::init_box(QGroupBox* m_box){

    hb1=new QHBoxLayout;
    hb2=new QHBoxLayout;
    hb3=new QHBoxLayout;
    hb4=new QHBoxLayout;
    label1=new QLabel("水平旋转:");
    label2=new QLabel("垂直旋转:");
    label3=new QLabel("主题:");
    label4=new QLabel("字体大小:");
    slider1=new QSlider;
    slider1->setOrientation(Qt::Horizontal);
    slider1->setTickPosition(QSlider::TicksBelow);
    slider1->setMinimum(5);
    slider1->setMaximum(85);
    slider2=new QSlider;
    slider2->setOrientation(Qt::Horizontal);
    slider2->setTickPosition(QSlider::TicksAbove);
    slider2->setMinimum(5);
    slider2->setMaximum(85);
    slider3=new QSlider;
    slider3->setRange(35,65);
    slider3->setOrientation(Qt::Horizontal);
    combox=new QComboBox;
    hb1->addWidget(label1);
    hb1->addWidget(slider1);
    hb2->addWidget(label2);
    hb2->addWidget(slider2);
    //hb3->addStretch(0);
    hb3->addWidget(label3);
    hb3->addWidget(combox);
    hb4->addWidget(label4);
    hb4->addWidget(slider3);
    vb=new QVBoxLayout;
    vb->addLayout(hb1);
    vb->addLayout(hb2);
    vb->addLayout(hb3);
    vb->addLayout(hb4);

    m_box->setLayout(vb);


//
//    connect(combox,SIGNAL(activated(int)),this,SLOT(slot_combox()));

    return m_box;
}
//设置图形水平方向旋转
void init_widget::slot_slider1(int num)
{
    //qDebug()<<num;
    x_roation=num;
    m_bars->scene()->activeCamera()->setCameraPosition(x_roation, y_roation);
}
//设置图形垂直方向旋转
void init_widget::slot_slider2(int num)
{
    y_roation=num;
    m_bars->scene()->activeCamera()->setCameraPosition(x_roation, y_roation);
}
//设置标签字体的大小
void init_widget::slot_slider3(int num)
{
    QFont font = m_bars->activeTheme()->font();
    font.setPointSize(num);
    m_bars->activeTheme()->setFont(font);
}
void init_widget::slot_combox()
{

}

